package org.kumas.sgrpc.common.serialize.java;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import org.kumas.sgrpc.common.URL;
import org.kumas.sgrpc.common.serialize.ObjectInput;
import org.kumas.sgrpc.common.serialize.ObjectOutput;
import org.kumas.sgrpc.common.serialize.Serialization;

import static org.kumas.sgrpc.common.serialize.Constants.COMPACTED_JAVA_SERIALIZATION_ID;

public class CompactedJavaSerialization implements Serialization {

    @Override
    public byte getContentTypeId() {
        return COMPACTED_JAVA_SERIALIZATION_ID;
    }

    @Override
    public String getContentType() {
        return "x-application/compactedjava";
    }

    @Override
    public ObjectOutput serialize(URL url, OutputStream out) throws IOException {
        return new JavaObjectOutput(out, true);
    }

    @Override
    public ObjectInput deserialize(URL url, InputStream is) throws IOException {
        return new JavaObjectInput(is, true);
    }

}